package com.iplant.mes.service.po.sfc;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.mes.service.mesenum.sfc.SFCTaskStatus;
import com.iplant.pdm.service.basicenum.fpc.FPCCheckType;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

@DBBasePO(TableName = "sfc_task_ipt", Name = false, Active = false, Schemas = DBSchemas.MES,
        CheckName = {"Code", "OrderID,RoutePartID,RoutePartPointID,ComponentCode,Type,ProductRepairID"}, CodeAuto =
        true, CodePrefix = "SIPT" +
        "-{yyMMdd}-",
        CodeNum = 4)
public class SFCTaskIPT extends BasePO {
    @DBCondition
    @DBField
    public int OrderID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBField
    public String OrderNo = "";

    @DBCondition
    @DBField
    public int RoutePartID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fpc_routepart", tableAsName = "fpc_routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public String RoutePartName = "";

    @DBCondition
    @DBField
    public int RoutePartPointID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public String RoutePartPointName = "";

    @DBJoin(name = "OrderID", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public String RoutePartPointOrder = "";

    @DBCondition
    @DBJoin(name = "ComponentType", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public int ComponentType = 0;

    @DBCondition
    @DBField
    public int ProductID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public String ProductCode = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public String ProductName = "";

    @DBJoin(name = "ComponentNumber", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public int ComponentNumber = 1;

    @DBField
    public int TaskPartID;
    @DBField
    public int TaskPartPointID;

    @DBCondition
    @DBField
    public int TaskPartPointDayID;

    @DBCondition
    @DBField
    public int TaskSelfID;

    @DBJoin(name = "Code", tableName = "sfc_task_self", tableAsName = "sfc_task_self1", Schemas = DBSchemas.MES,
            MainTableField = "TaskSelfID")
    public String TaskSelfCode="";

    /**
     * 车间ID
     */
    @DBCondition
    @DBField
    public int WorkShopID = 0;
    @DBJoin(name = "Name", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopName = "";
    /**
     * 车间编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopCode = "";

    /**
     * 工区ID
     */
    @DBCondition
    @DBField
    public int WorkAreaID = 0;
    /**
     * 工区名称
     */
    @DBJoin(name = "Name", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaName = "";
    /**
     * 工区编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaCode = "";

    /**
     * 工位ID
     */
    @DBCondition
    @DBField
    public int StationID = 0;
    /**
     * 工位名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fmc_station", tableAsName = "station1", Schemas = DBSchemas.Basic,
            JoinIndex = 4,
            MainTableField = "StationID")
    public String StationName = "";
    /**
     * 工位编码
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "fmc_station", tableAsName = "station1", Schemas = DBSchemas.Basic,
            JoinIndex = 4,
            MainTableField = "StationID")
    public String StationCode = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "StaStartTime", ParamName2 = "StaEndTime")
    @DBField
    public Calendar StationDate = Calendar.getInstance();

    @DBCondition
    @DBField
    public int ShiftType = 0;

    /**
     * 原计划数量
     */
    @DBJoin(name = "PlantNum", tableName = "aps_task_partpoint_day", tableAsName = "aps_task_partpoint_day1", Schemas =
            DBSchemas.APS,
            JoinIndex = 4,
            MainTableField = "TaskPartPointDayID")
    public float SPlantNum = 0.0f;

    /**
     * 当班次班组长确定计划数
     */
    @DBJoin(name = "DPlantNum", tableName = "aps_task_partpoint_day", tableAsName = "aps_task_partpoint_day1", Schemas =
            DBSchemas.APS,
            JoinIndex = 4,
            MainTableField = "TaskPartPointDayID")
    public float DPlantNum = 0.0f;
    /**
     * 工序任务在某个工位的计划数
     */
    @DBJoin(name = "PlantNum", tableName = "sfc_task_self", tableAsName = "sfc_task_self1", Schemas = DBSchemas.MES,
            JoinIndex = 2,
            MainTableField = "TaskSelfID")
    public float PlantNum = 0.0f;

    /**
     * 实际执行数量
     */
    @DBField
    public float ActNum = 0.0f;

    /**
     * 作业人ID（同一张检验单支持多人一起作业）
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.findInSet)
    @DBField
    public List<Integer> WorkerIDList = new ArrayList<>();
    /**
     * 作业人名称
     */
    @DBJoin(name = "Name", tableName = "mbs_user", tableAsName = "mbs_user1", Schemas = DBSchemas.Basic,
            MainTableField = "WorkerIDList")
    public String WorkerName = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.in)
    @DBField
    public int Status = 0;

    public String StatusText = "";

    /**
     * 检验类型
     */
    @DBCondition
    @DBField
    public int Type = 0;

    public String TypeText = "";

    /**
     * 元件编码
     */
    @DBCondition
    @DBField
    public String ComponentCode = "";

    /**
     * 是否已报工
     */
    @DBCondition
    @DBField
    public int IsReported = 0;

    /**
     * 报工单ID
     */
    @DBCondition
    @DBField
    public int TaskReportID = 0;

    /**
     * 结果
     */
    @DBCondition
    @DBField
    public int Result = 0;

    /**
     * 是否为返修检验单
     */
    @DBCondition
    @DBField
    public int IsRepairPlan = 0;
    /**
     * 返修单ID
     */
    @DBCondition
    @DBField
    public int ProductRepairID = 0;

    /**
     * 首检标记
     */
    @DBCondition
    @DBField
    public int FirstFlag = 0;

    /**
     * 抽检标记
     */
    @DBCondition
    @DBField
    public int SamplingFlag = 0;

    @JsonProperty("OrderID")
    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    @JsonProperty("OrderNo")
    public String getOrderNo() {
        return OrderNo;
    }

    public void setOrderNo(String orderNo) {
        OrderNo = orderNo;
    }

    @JsonProperty("RoutePartID")
    public int getRoutePartID() {
        return RoutePartID;
    }

    public void setRoutePartID(int routePartID) {
        RoutePartID = routePartID;
    }

    @JsonProperty("RoutePartName")
    public String getRoutePartName() {
        return RoutePartName;
    }

    public void setRoutePartName(String routePartName) {
        RoutePartName = routePartName;
    }

    @JsonProperty("RoutePartPointID")
    public int getRoutePartPointID() {
        return RoutePartPointID;
    }

    public void setRoutePartPointID(int routePartPointID) {
        RoutePartPointID = routePartPointID;
    }

    @JsonProperty("RoutePartPointName")
    public String getRoutePartPointName() {
        return RoutePartPointName;
    }

    public void setRoutePartPointName(String routePartPointName) {
        RoutePartPointName = routePartPointName;
    }

    @JsonProperty("ComponentType")
    public int getComponentType() {
        return ComponentType;
    }

    public void setComponentType(int componentType) {
        ComponentType = componentType;
    }

    @JsonProperty("TaskPartID")
    public int getTaskPartID() {
        return TaskPartID;
    }

    public void setTaskPartID(int taskPartID) {
        TaskPartID = taskPartID;
    }

    @JsonProperty("TaskPartPointID")
    public int getTaskPartPointID() {
        return TaskPartPointID;
    }

    public void setTaskPartPointID(int taskPartPointID) {
        TaskPartPointID = taskPartPointID;
    }

    @JsonProperty("TaskStationID")
    public int getTaskPartPointDayID() {
        return TaskPartPointDayID;
    }

    public void setTaskPartPointDayID(int taskPartPointDayID) {
        TaskPartPointDayID = taskPartPointDayID;
    }

    @JsonProperty("WorkShopID")
    public int getWorkShopID() {
        return WorkShopID;
    }

    public void setWorkShopID(int workShopID) {
        WorkShopID = workShopID;
    }

    @JsonProperty("WorkShopName")
    public String getWorkShopName() {
        return WorkShopName;
    }

    public void setWorkShopName(String workShopName) {
        WorkShopName = workShopName;
    }

    @JsonProperty("WorkShopCode")
    public String getWorkShopCode() {
        return WorkShopCode;
    }

    public void setWorkShopCode(String workShopCode) {
        WorkShopCode = workShopCode;
    }

    @JsonProperty("WorkAreaID")
    public int getWorkAreaID() {
        return WorkAreaID;
    }

    public void setWorkAreaID(int workAreaID) {
        WorkAreaID = workAreaID;
    }

    @JsonProperty("WorkAreaName")
    public String getWorkAreaName() {
        return WorkAreaName;
    }

    public void setWorkAreaName(String workAreaName) {
        WorkAreaName = workAreaName;
    }

    @JsonProperty("WorkAreaCode")
    public String getWorkAreaCode() {
        return WorkAreaCode;
    }

    public void setWorkAreaCode(String workAreaCode) {
        WorkAreaCode = workAreaCode;
    }

    @JsonProperty("StationID")
    public int getStationID() {
        return StationID;
    }

    public void setStationID(int stationID) {
        StationID = stationID;
    }

    @JsonProperty("StationName")
    public String getStationName() {
        return StationName;
    }

    public void setStationName(String stationName) {
        StationName = stationName;
    }

    @JsonProperty("StationCode")
    public String getStationCode() {
        return StationCode;
    }

    public void setStationCode(String stationCode) {
        StationCode = stationCode;
    }

    @JsonProperty("StationDate")
    public Calendar getStationDate() {
        return StationDate;
    }

    public void setStationDate(Calendar stationDate) {
        StationDate = stationDate;
    }

    @JsonProperty("ShiftType")
    public int getShiftType() {
        return ShiftType;
    }

    public void setShiftType(int shiftType) {
        ShiftType = shiftType;
    }

    @JsonProperty("ProductID")
    public int getProductID() {
        return ProductID;
    }

    public void setProductID(int productID) {
        ProductID = productID;
    }

    @JsonProperty("ProductCode")
    public String getProductCode() {
        return ProductCode;
    }

    public void setProductCode(String productCode) {
        ProductCode = productCode;
    }

    @JsonProperty("ComponentNumber")
    public int getComponentNumber() {
        return ComponentNumber;
    }

    public void setComponentNumber(int componentNumber) {
        ComponentNumber = componentNumber;
    }

    @JsonProperty("SPlantNum")
    public float getSPlantNum() {
        return SPlantNum;
    }

    public void setSPlantNum(float SPlantNum) {
        this.SPlantNum = SPlantNum;
    }

    @JsonProperty("DPlantNum")
    public float getDPlantNum() {
        return DPlantNum;
    }

    public void setDPlantNum(float DPlantNum) {
        this.DPlantNum = DPlantNum;
    }

    @JsonProperty("PlantNum")
    public float getPlantNum() {
        return PlantNum;
    }

    public void setPlantNum(float plantNum) {
        PlantNum = plantNum;
    }

    @JsonProperty("ActNum")
    public float getActNum() {
        return ActNum;
    }

    public void setActNum(float actNum) {
        ActNum = actNum;
    }

    @JsonProperty("WorkerIDList")
    public List<Integer> getWorkerIDList() {
        return WorkerIDList;
    }

    public void setWorkerIDList(List<Integer> workerIDList) {
        WorkerIDList = workerIDList;
    }

    @JsonProperty("WorkerName")
    public String getWorkerName() {
        return WorkerName;
    }

    public void setWorkerName(String workerName) {
        WorkerName = workerName;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("StatusText")
    public String getStatusText() {
        StatusText = SFCTaskStatus.getEnumType(Status).getLabel();
        return StatusText;
    }

    public void setStatusText(String statusText) {
        StatusText = statusText;
    }

    @JsonProperty("Type")
    public int getType() {
        return Type;
    }

    public void setType(int type) {
        Type = type;
    }

    @JsonProperty("TypeText")
    public String getTypeText() {
        TypeText = FPCCheckType.getEnumType(Type).getLabel();
        return TypeText;
    }

    public void setTypeText(String typeText) {
        TypeText = typeText;
    }

    @JsonProperty("TaskSelfID")
    public int getTaskSelfID() {
        return TaskSelfID;
    }

    public void setTaskSelfID(int taskSelfID) {
        TaskSelfID = taskSelfID;
    }

    @JsonProperty("ComponentCode")
    public String getComponentCode() {
        return ComponentCode;
    }

    public void setComponentCode(String componentCode) {
        ComponentCode = componentCode;
    }

    @JsonProperty("TaskReportID")
    public int getTaskReportID() {
        return TaskReportID;
    }

    public void setTaskReportID(int taskReportID) {
        TaskReportID = taskReportID;
    }

    @JsonProperty("IsReported")
    public int getIsReported() {
        return IsReported;
    }

    public void setIsReported(int isReported) {
        IsReported = isReported;
    }

    @JsonProperty("Result")
    public int getResult() {
        return Result;
    }

    public void setResult(int result) {
        Result = result;
    }

    @JsonProperty("ProductName")
    public String getProductName() {
        return ProductName;
    }

    public void setProductName(String productName) {
        ProductName = productName;
    }

    @JsonProperty("IsRepairPlan")
    public int getIsRepairPlan() {
        return IsRepairPlan;
    }

    public void setIsRepairPlan(int isRepairPlan) {
        IsRepairPlan = isRepairPlan;
    }

    @JsonProperty("ProductRepairID")
    public int getProductRepairID() {
        return ProductRepairID;
    }

    public void setProductRepairID(int productRepairID) {
        ProductRepairID = productRepairID;
    }

    @JsonProperty("RoutePartPointOrder")
    public String getRoutePartPointOrder() {
        return RoutePartPointOrder;
    }

    public void setRoutePartPointOrder(String routePartPointOrder) {
        RoutePartPointOrder = routePartPointOrder;
    }

    @JsonProperty("FirstFlag")
    public int getFirstFlag() {
        return FirstFlag;
    }

    public void setFirstFlag(int firstFlag) {
        FirstFlag = firstFlag;
    }

    @JsonProperty("SamplingFlag")
    public int getSamplingFlag() {
        return SamplingFlag;
    }

    public void setSamplingFlag(int samplingFlag) {
        SamplingFlag = samplingFlag;
    }

    @JsonProperty("TaskSelfCode")
    public String getTaskSelfCode() {
        return TaskSelfCode;
    }

    public void setTaskSelfCode(String taskSelfCode) {
        TaskSelfCode = taskSelfCode;
    }
}
